// components/diy/menu/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    diyPramas:{
      type:Object
    },
    diyStyle:{
      type:Object
    },
    diyData:{
      type:Object
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    swiperCurrent: 0,
    slider:[],
    swiperBtnHeight:0, //按钮组高度
    lineSize:0, //行数
    pageSize:0  //页数
  },

  /**
   * 组件的方法列表
   */
  methods: {
      //轮播图的切换事件
      swiperChange: function(e){
        //只要把切换后当前的index传给<swiper>组件的current属性即可
        this.setData({
          swiperCurrent: e.detail.current
        })
      },
      
      //点击指示点切换
      chuangEvent: function(e){
        this.setData({
          swiperCurrent: e.currentTarget.id
        })
      }
  },
  ready: function(){
    var rownum = this.properties.diyStyle.rownum ; //每行显示个数
    var pagenum = this.properties.diyStyle.pagenum; //每页显示个数
    var num = this.data.diyData.length; //总共按钮数
    var pageSize = 0;//总共页数
    if(num%pagenum == 0){
      pageSize = parseInt(num/pagenum)
    }else{
      pageSize = parseInt(num/pagenum) + 1
    }
    var lineSize = 0;//每页行数
    if(pageSize <= 1){
      if(num%rownum == 0){
        lineSize = parseInt(num/rownum);
      }else{
        lineSize = parseInt(num/rownum) + 1;
      }  
    }else{
        if(pagenum%rownum == 0){
          lineSize = parseInt(pagenum/rownum);
        }else{
          lineSize = parseInt(pagenum/rownum) + 1;
        }
    }
    var height = 68 * lineSize + 10 * (2 * lineSize)
    this.setData({
      swiperBtnHeight:height,
      pageSize:pageSize,
      lineSize:lineSize
    }) 
  }
})
